﻿using Microsoft.SharePoint.Client.Services;
using System.ServiceModel.Activation;
using System;
using Microsoft.SharePoint;
using System.Collections;
using PlanB.ShareDove.ConferenceOrganization.ServiceLayer;
using PlanB.ShareDove.ConferenceOrganization.ServiceLayer.ServiceFacade;
using PlanB.ShareDove.ConferenceOrganization.ServiceLayer.ServiceFacade.Entities;
using System.Collections.Generic;

namespace ShareDoveRestService
{
    [BasicHttpBindingServiceMetadataExchangeEndpoint]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
    public class ShareDove : IShareDove
    {

        public SessionsList GetSessions()
        {

            SessionsList allSessions = new SessionsList();

            string shareDoveSite = "http://sharedove.cld.sr/";
            string shareDoveWeb = "SahreConf2012";

            ServiceFacade facade = new ServiceFacade();

            facade.DataLayerImplementation = "PlanB.ShareDove.ConferenceOrganization.SharePointDataLayer, Version=0.0.0.1, Culture=neutral, PublicKeyToken=79ea5ba3438af0bf";
            facade.DataLayerClass = "PlanB.ShareDove.ConferenceOrganization.DataLayer.SharePointDataLayer.SharePointDataLayer";
            facade.SiteName = shareDoveSite;
            facade.WebName = shareDoveWeb;

            List<ConferenceSessionLite> sessions = facade.GetAgendaForDay(new DateTime(2012, 06, 20));

            allSessions.AllSessions = sessions.ToArray();

            return allSessions;
        }


        public ConferenceSessionLite[] GetSessionsArray()
        {

            SessionsList allSessions = new SessionsList();

            string shareDoveSite = "http://sharedove.cld.sr/";
            string shareDoveWeb = "SahreConf2012";

            ServiceFacade facade = new ServiceFacade();

            facade.DataLayerImplementation = "PlanB.ShareDove.ConferenceOrganization.SharePointDataLayer, Version=0.0.0.1, Culture=neutral, PublicKeyToken=79ea5ba3438af0bf";
            facade.DataLayerClass = "PlanB.ShareDove.ConferenceOrganization.DataLayer.SharePointDataLayer.SharePointDataLayer";
            facade.SiteName = shareDoveSite;
            facade.WebName = shareDoveWeb;

            List<ConferenceSessionLite> sessions = facade.GetAgendaForDay(new DateTime(2012, 06, 20));

            allSessions.AllSessions = sessions.ToArray();

            return (allSessions.AllSessions);
        }

        public Dummy[] GetDummy()
        {
            List<Dummy> dummies = new List<Dummy>();
            dummies.Add(new Dummy() { id = "1", title = "First", datum = DateTime.Now.ToString() });
            dummies.Add(new Dummy() { id = "2", title = "Second", datum = DateTime.Now.ToString() });
            dummies.Add(new Dummy() { id = "3", title = "Third", datum = DateTime.Now.ToString() });
            dummies.Add(new Dummy() { id = "4", title = "Fourth", datum = DateTime.Now.ToString() });
            dummies.Add(new Dummy() { id = "5", title = "Fifth", datum = DateTime.Now.ToString() });

            return dummies.ToArray();
        }

    }
}
